/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.klikmee.sms.core.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * 
 * @author makcro
 */
@Entity
@Table(name = "bulkmessage")
@NamedQueries({
		@NamedQuery(name = "BulkMessage.findAll", query = "SELECT b FROM BulkMessage b"),
		@NamedQuery(name = "BulkMessage.findById", query = "SELECT b FROM BulkMessage b WHERE b.id = :id"),
		@NamedQuery(name = "BulkMessage.findByToNumber", query = "SELECT b FROM BulkMessage b WHERE b.toNumber = :toNumber"),
		@NamedQuery(name = "BulkMessage.findBySenderId", query = "SELECT b FROM BulkMessage b WHERE b.senderId = :senderId"),
		@NamedQuery(name = "BulkMessage.findByText", query = "SELECT b FROM BulkMessage b WHERE b.text = :text"),
		@NamedQuery(name = "BulkMessage.findByState", query = "SELECT b FROM BulkMessage b WHERE b.state = :state"),
		@NamedQuery(name = "BulkMessage.findByStateChangeTime", query = "SELECT b FROM BulkMessage b WHERE b.stateChangeTime = :stateChangeTime"),
		@NamedQuery(name = "BulkMessage.findByDeliveryStatus", query = "SELECT b FROM BulkMessage b WHERE b.deliveryStatus = :deliveryStatus"),
		@NamedQuery(name = "BulkMessage.findByDeliveryStatusChangeTime", query = "SELECT b FROM BulkMessage b WHERE b.deliveryStatusChangeTime = :deliveryStatusChangeTime"),
		@NamedQuery(name = "BulkMessage.findByProvidersIdAndName", query = "SELECT b FROM BulkMessage b WHERE b.prividersId = :prividersId AND b.provider.name = :providerName")})
public class BulkMessage implements Serializable {
	private static final long		serialVersionUID	= 1L;
	@Id
	@GeneratedValue(generator = "OutgoingIdGenerator", strategy = GenerationType.TABLE)
	@Basic(optional = false)
	@Column(name = "Id", nullable = false)
	private Long					id;

	@Column(name = "ToNumber", length = 50)
	private String					toNumber;

	@Column(name = "SenderId", length = 50)
	private String					senderId;

	@Column(name = "Text", length = 1024)
	private String					text;
	@Column(name = "State")
	private Integer					state;
	@Column(name = "StateChangeTime")
	@Temporal(TemporalType.TIMESTAMP)
	private Date					stateChangeTime;
	@Column(name = "DeliveryStatus")
	private Integer					deliveryStatus;
	@Column(name = "DeliveryStatusChangeTime")
	@Temporal(TemporalType.TIMESTAMP)
	private Date					deliveryStatusChangeTime;
	@Column(name = "SendingTime")
	@Temporal(TemporalType.TIMESTAMP)
	private Date					sendingTime;
	@Column(name = "ProvidersId", length = 256)
	private String					prividersId;
	@JoinColumn(name = "ProviderId", referencedColumnName = "id")
	@ManyToOne
	private Provider				provider;
	@JoinColumn(name = "ChargingId", referencedColumnName = "Id")
	@ManyToOne
	private ServiceChargingCategory	chargingCategory;

	public BulkMessage() {
	}

	public BulkMessage( Long id ) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setId( Long id ) {
		this.id = id;
	}

	public String getToNumber() {
		return toNumber;
	}

	public void setToNumber( String toNumber ) {
		this.toNumber = toNumber;
	}

	public String getSenderId() {
		return senderId;
	}

	public void setSenderId( String senderId ) {
		this.senderId = senderId;
	}

	public String getText() {
		return text;
	}

	public void setText( String text ) {
		this.text = text;
	}

	public Integer getState() {
		return state;
	}

	public void setState( Integer state ) {
		this.state = state;
		setStateChangeTime( new Date() );
	}

	public Date getStateChangeTime() {
		return stateChangeTime;
	}

	public void setStateChangeTime( Date stateChangeTime ) {
		this.stateChangeTime = stateChangeTime;
	}

	public Integer getDeliveryStatus() {
		return deliveryStatus;
	}

	public void setDeliveryStatus( Integer deliveryStatus ) {
		this.deliveryStatus = deliveryStatus;
		setDeliveryStatusChangeTime( new Date() );
	}

	public Date getDeliveryStatusChangeTime() {
		return deliveryStatusChangeTime;
	}

	public void setDeliveryStatusChangeTime( Date deliveryStatusChangeTime ) {
		this.deliveryStatusChangeTime = deliveryStatusChangeTime;
	}

	public void setSendingTime( Date sendingTime ) {
		this.sendingTime = sendingTime;
	}

	public Date getSendingTime() {
		return sendingTime;
	}

	public Provider getProvider() {
		return provider;
	}

	public void setProvider( Provider providerId ) {
		this.provider = providerId;
	}

	public void setChargingCategory( ServiceChargingCategory chargingCategory ) {
		this.chargingCategory = chargingCategory;
	}

	public ServiceChargingCategory getChargingCategory() {
		return chargingCategory;
	}

	public String getPrividersId() {
		return prividersId;
	}

	public void setPrividersId( String prividersId ) {
		this.prividersId = prividersId;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals( Object object ) {
		if (!(object instanceof BulkMessage)) {
			return false;
		}
		BulkMessage other = (BulkMessage) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals( other.id ))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "com.klikmee.sms.core.entities1.BulkMessage[ id=" + id + " ]";
	}

}
